// by Xeno
//#define __DEBUG__
#define THIS_FILE "fn_save_respawngear.sqf"
#include "x_setup.sqf"

private ["_handgunmuzzles"];
_p = player;
// oh boy... who designed this item system where you are not able to simply read primary and secondary magazines
// furthermore you are not able to retrieve those from dead units
_assigneditems = (assignedItems _p) - [headgear _p] - [goggles _p];
__TRACE_1("","_assigneditems");
__pSetVar [QGVAR(respawn_assignedItems), _assigneditems];

_magsammofull = magazinesAmmoFull _p;
__TRACE_1("","_magsammofull");
__pSetVar [QGVAR(respawn_magazinesAmmoFull), _magsammofull];
#ifdef __DEBUG__
{
	__TRACE_1("","_x");
} forEach _magsammofull;
#endif

_handgun_pweap = handgunWeapon _p;
__TRACE_1("","_handgun_pweap");
__pSetVar [QGVAR(respawn_handgunWeapon), _handgun_pweap];
_sec_pweap = secondaryWeapon _p;
__TRACE_1("","_sec_pweap");
__pSetVar [QGVAR(respawn_secondaryWeapon), _sec_pweap];
_prim_pweap = primaryWeapon _p;
__TRACE_1("","_prim_pweap");
__pSetVar [QGVAR(respawn_primaryWeapon), _prim_pweap];

_prim_weapItems = primaryWeaponItems _p;
__TRACE_1("","_prim_weapItems");
__pSetVar [QGVAR(respawn_primweapitems), _prim_weapItems];
_sec_weapItems = secondaryWeaponItems _p;
__TRACE_1("","_sec_weapItems");
__pSetVar [QGVAR(respawn_secweapitems), _sec_weapItems];
_handgun_Items = handgunItems _p;
__TRACE_1("","_handgun_Items");
__pSetVar [QGVAR(respawn_handgunItems), _handgun_Items];
_uniform = uniform _p;
__TRACE_1("","_uniform");
__pSetVar [QGVAR(respawn_uniform), _uniform];

_vest = vest _p;
__TRACE_1("","_vest");
__pSetVar [QGVAR(respawn_vest), _vest];

_backpack = backpack _p;
__TRACE_1("","_backpack");
__pSetVar [QGVAR(respawn_backpack), _backpack];

if (_backpack != "") then {
	_backpackcargo = backpackCargo (unitBackpack _p);
	__TRACE_1("","_backpackcargo");
	__pSetVar [QGVAR(respawn_backpack_backpack), _backpackcargo];
} else {
	__pSetVar [QGVAR(respawn_backpack_backpack), []];
};

_goggles = goggles _p;
__TRACE_1("","_goggles");
__pSetVar [QGVAR(respawn_goggles), _goggles];
_headgear = headgear _p;
__TRACE_1("","_headgear");
__pSetVar [QGVAR(respawn_headgear), _headgear];

_items = items _p;
__TRACE_1("","_items");
__pSetVar [QGVAR(respawn_items), _items];